const Request = require('./request.js');
const Config = require('../config.js').Config;

const AgentAPI = {
  // 注册新用户
  register: 'wxapi/new/register',
  // 获取openid
  getMember: 'wxapi/user/getMember',
  // 获取员工信息
  getAdmin: 'wxapi/admin/getUsers',
  // 绑定
  bindAccount: 'wxapi/user/bindMemberAccount',
  //个人信息
  getMemberDetail: 'wxapi/user/memberDetail',
  // 获取手机号码
  getPhoneNumber: 'wxapi/user/getPhoneNumber',
  // 注销登录
  logout: 'wxapi/user/unbind',

  // 获取验证码
  sendSMSCode: 'wxapi/new/sendingsms',
  // 验证验证码
  checkSMSCode: 'wxapi/new/checkverification',
  // 获取省市区列表
  getAddressList: 'wxapi/user/regionList',

  // 修改昵称
  modifyName: 'wxapi/user/updatename',
  // 修改手机
  modifyMobile: 'wxapi/user/updatemobile',
  // 修改密码
  modifyPassword: 'wxapi/user/passUpdate',
  // 找回密码
  notLoginPassUpdate: 'wxapi/notLogin/passUpdate',
  // 个人中心图片列表
  getPersonalPhotoList: 'wxapi/user/memberVipAlbum',
  // 个人中心相册上传
  upLoadPersonalPhoto: 'wxapi/user/addAlbum',
  // 个人中心相册删除
  deletePersonalPhoto: 'wxapi/user/delAlbum',

  // 会员类型列表
  getMemberTypeList: 'wxapi/user/nidustryList',
  // 提交认证
  submitAuthentication: 'wxapi/user/authentication',

  // 获取首页配置
  getWxappStyle: 'wxapi/home/config',
  // 获取小程序调试配置
  getWxappDebugConfig: 'wxapi/wxapp/debugConfig',
  // 获取首页页面布局
  getWxappHomepage: 'wxapi/home/page',
  // 获取formId
  addFormId: 'wxapi/get/formId',
  // 获取导航栏配置
  getTabbarList: 'wxapi/home/NavigationBar',

  //获取使用帮助
  getUseHelp: 'wxapi/user/getNewsList',
  //获取关于我们
  getAbout: 'wxapi/user/getAbout',
  // 获取企业展示
  getEnterpriseDisplay: 'wxapi/home/companyInfo',

  // 获取留言反馈列表
  getProposalList: 'wxapi/activity/memberProposalList',
  // 提交反馈留言
  submitProposal: 'wxapi/activity/memberAddProposal',

  // 产品类型
  getGoodsTypeList: 'wxapi/crm/typeList',
  // 商品列表
  goodsList: 'wxapi/crm/goodsList',
  // 订单列表
  memberOrder: 'wxapi/user/memberOrder',
  //商品详情
  goodsDetail: 'wxapi/crm/goodsDetail',
  //提交订单
  submitOrder: 'wxapi/crm/submitOrder',
  //订单详情
  memberOrderDetail: 'wxapi/crm/memberOrderDetail',
  //操作订单
  orderAction: 'wxapi/crm/orderAction',

  // 获取查询客户订单列表
  getTencentCloudOrderList: 'wxapi/tencent/selectorder',
  // 获取我的订单
  getMyTencentCloudOrderList: 'wxapi/user/memberOrder',
  // 腾讯云订单代付
  payTencentCloudOrder: 'wxapi/tencent/payOrder',
  // 订单操作
  tencentCloudOrderAction: 'wxapi/crm/orderAction',

  // 获取活动列表
  getActivityList: 'wxapi/activity/getList',
  // 获取往期活动列表:
  getEndActivity: 'wxapi/activity/endActivity',
  // 获取活动详情
  getActivityDetails: 'wxapi/activity/getInfo',
  // 提交报名参加活动
  joinActivity: 'wxapi/activity/singUp',
  // 活动评论列表
  getActivityCommentList: 'wxapi/activity/commentList',
  // 我的评论列表
  getMineCommentList: 'wxapi/user/commentList',
  // 活动点赞
  doLikeActivity: 'wxapi/activity/spotFabulous',
  // 取消点赞
  cancelLikeActivity: 'wxapi/activity/cancelFabulous',
  // 我的点赞列表
  getMineLikeActivityList: 'wxapi/user/fabulousList',
  // 收藏活动
  doCollectionActivity: 'wxapi/activity/memberCollect',
  // 取消收藏活动
  cancelCollectionActivity: 'wxapi/activity/memberCancelCollect',
  // 我的收藏列表
  getMineCollectionActivityList: 'wxapi/user/collectList',
  // 我报名的活动
  getMineApplyActivity: 'wxapi/user/myActivity',
  // 我报名的活动详情
  getMineActivityDetails: 'wxapi/user/myActivityInfo',
  // 取消报名活动
  cancelJoinActivity: 'wxapi/activity/cancelSign',
  // 评论活动
  submitActivityFeedback: 'wxapi/activity/memberComment',
  // 参加活动人员列表
  joinMemberList: 'wxapi/activity/signUpPageList',

  // 通讯录列表
  getTelephoneBookList: 'wxapi/vip/list',
  // 通讯录详情
  getTelephoneBookDetails: 'wxapi/vip/info',
  // 获取相册列表
  getAlbumList: 'wxapi/vip/album',
  // 通讯录搜索
  searchTelephoneBook: 'wxapi/vip/search',

  // 获取新闻类型
  getNewsTypeList: 'wxapi/news/getTypeList',
  // 获取新闻列表
  getNewsList: 'wxapi/news/getTypeNewsList',
  // 获取新闻详情
  getNewsDetails: 'wxapi/news/newsInfo',

  // 获取视频新闻列表
  getVideoNewsList: 'wxapi/news/videoCenter',

  // 用户充值
  recharge: 'wxapi/charge/pay',
  // 钱包明细
  getWalletRecord: 'wxapi/user/transactionDetails',

  // 提交工单
  submitWorkOrder: 'wxapi/crm/workOrderSubmit',

  // 考试列表
  getExamList: 'wxapi/exam/examList',
  // 考试首页
  getExamIndex: 'wxapi/exam/getExamInfo',
  // 试题列表
  getExamQuestionList: 'wxapi/exam/getQuestionsList',
  // 考试预提交
  submitExamPreview: 'wxapi/exam/preSubmit',
  // 考试提交
  submitExam: 'wxapi/exam/examEndResult',
  // 剩余考试次数
  getRemainingExaminationsNumber: 'wxapi/exam/getExamNumber',
  // 考试解析
  getExamExplain: 'wxapi/exam/examExplain',
  // 考试排名
  getExamRanking: 'wxapi/exam/rankingList',
  // 考试结果
  getExamResultInfo: 'wxapi/exam/examResult',

  // 我的工单
  getMineFeedbackList: 'wxapi/work/myFeedbackList',
  // 提交工单
  submitFeedback: 'wxapi/work/workOrderSubmit',
  // 问题类别列表
  getFeedbackTypeList: 'wxapi/work/feedbackLabel',
  // 获取反馈服务范围
  getFeedbackAreaList: 'wxapi/work/getStreetList',
  // 获取服务热线
  getServiceHotLine: 'wxapi/hotline/list',
  // 工单详情
  getMineFeedbackDetails: 'wxapi/work/feedbackInfo',
  // 继续反馈
  submitContinueFeedback: 'wxapi/work/supplementWorkOrder',
  // 结束工单
  finisFeedback: 'wxapi/work/endWorkOrder',

  // 物品申请
  getApplicationGoodsList: 'wxapi/apply/getAll',
  // 申请说明
  geApplicationGoodsDetails: 'wxapi/apply/getApplyInfo',
  // 提交申请
  submitApplicationGoods: 'wxapi/apply/toSaveInfo',

  // 获取超级工单设置信息
  getSuperWorkOrderConfig: '/wxapi/newWork/getSettingInfo',
  // 获取工单列表
  getSuperWorkOrderTypeList: 'wxapi/newWork/getClassList',
  // 获取工单填写表单信息
  getSuperWorkOrderDetails: '/wxapi/newWork/getWorkOrderInfo',
  // 提交超级工单
  submitSuperWorkOrder: '/wxapi/newWork/toSaveWorkOrder',
  // 获取我的反馈列表
  getMySuperWorkOrderList: '/wxapi/newWork/getWorkList',
  // 获取工单详情
  getMySuperWorkOrderDetails: '/wxapi/newWork/getWorkOrderDetail',
  // 获取支付信息
  getSuperWorkOrderPayData: 'wxapi/newWork/applyPay',
  // 提交继续反馈
  submitSuperWorkOrderAgain: 'wxapi/newWork/saveFeedBack'
};

const AdminAPI = {
  //获取用户信息
  getUsers: 'api/crm/getUsers',
  //绑定用户信息
  setUsers: 'api/crm/setUsers',
  //根据openid获取用户信息
  getUsersInfo: 'api/crm/getUsersInfo',
  //获取用户工作状态
  getWorkStatus: 'api/crm/getWorkStatus',
  //更改工作状态
  updateWorkStatus: 'api/crm/updateWorkStatus',
  //修改管理员信息
  updateUsers: 'api/crm/updateUsers',
  //获取部门信息
  getBranchs: 'api/crm/getBranchs',
  // 注销登录
  logout: 'api/crm/unbind',

  // 获取首页配置
  getWxappStyle: 'api/crm/getWxconfig',
  // 获取首页页面布局
  getWxappHomepage: 'api/crm/homePage',
  // 获取formId
  addFormId: 'api/crm/getFormId',

  //获取首页各种数据
  getGlobalData: 'api/crm/getGlobalData',
  //获取业绩排行榜
  getRankingList: 'api/crm/getRankingList',
  //获取今日指派
  getTodayCustomer: 'api/crm/getTodayCustomer',

  //获取提成记录
  getBonusList: 'api/crm/getBonusList',
  //获取提现记录
  getTakeMoneyList: 'api/crm/getTakeMoneyList',
  //提现
  takeMoney: 'api/crm/takeMoney',

  //获取关于我们
  getAbout: 'api/crm/getAbout',
  //获取最新新闻
  getNews: 'api/crm/getNews',

  //添加客户
  createCustomer: 'api/crm/createCustomer',
  //获取客户来
  getSources: 'api/crm/getSources',
  //请求项目列表
  getProjects: 'api/crm/getProjects',
  //获取客户详细信息
  getCustomer: 'api/crm/getCustomer',
  //获取沟通日志
  getCommunicateLog: 'api/crm/getCommunicateLog',
  //修改客户信息
  updateCustomer: 'api/crm/updateCustomer',
  //获取客户列表
  getCustomerList: 'api/crm/getCustomerList',
  //添加沟通记录
  createCommLog: 'api/crm/createCommLog',

  // 考试列表
  getExamList: 'api/crm/examList',
  // 考试首页
  getExamIndex: 'api/crm/getExamInfo',
  // 试题列表
  getExamQuestionList: 'api/crm/getQuestionsList',
  // 考试预提交
  submitExamPreview: 'api/crm/preSubmit',
  // 考试提交
  submitExam: 'api/crm/examEndResult',
  // 剩余考试次数
  getRemainingExaminationsNumber: 'api/crm/getExamNumber',
  // 考试解析
  getExamExplain: 'api/crm/examExplain',
  // 考试排名
  getExamRanking: 'api/crm/rankingList',
  // 考试结果
  getExamResultInfo: 'api/crm/examResult',

  // 反馈中心列表
  getFeedbackList: 'api/work/adminFeedbackList',
  // 反馈详情
  getFeedbackDetails: 'api/work/feedbackInfo',
  // 接收反馈
  doAcceptFeedback: 'api/work/acceptWorkOrder',
  // 反馈回复
  doReplyFeedback: 'api/work/adminWorkOrderSubmit',
  // 转单记录
  loadTransferFeedbackLog: 'api/work/changeOrderLog',
  // 申请转单
  applyTransferFeedback: 'api/work/transferWorkOrder',

  // 工单中心列表
  getSuperWorkOrderList: 'api/newWork/getWorkOrderList',
  // 工单详情
  getSuperWorkOrderDetails: 'api/newWork/getWorkOrderDetail',
  // 接收工单
  doAcceptSuperWorkOrder: 'api/newWork/workOrderSignIn',
  // 工单回复
  doReplySuperWorkOrder: 'api/newWork/saveFeedBack',
  // 转单记录
  loadTransferSuperWorkOrderLog: 'api/newWork/getOrderChangeList',
  // 申请转单
  applyTransferSuperWorkOrder: 'api/newWork/transferWorkOrder',
  // 结单
  doFinishSuperWorkOrder: 'api/newWork/workOrderFinish',

  // 腾讯云插件
  // 获取我的客户列表
  getTencentCouldCustomerList: 'api/tencent/searchCustomerList',
  // 获取我的业务员列表
  getTencentCouldSalerList: 'api/tencent/getSaleByUser',
  // 获取客户等级及余额
  getTencentCouldCustomerBalance: 'api/tencent/getCustomerInfo',
  // 转账
  doRechangeToTencentCouldCustomer: 'api/tencent/getCustomerTransferMoney',
  // 客户审核
  doReviewTencentCouldCustomer: 'api/tencent/auditCustomer',
  // 获取腾讯云客户订单
  getTencentCouldCustomerOrderListHistroy: 'api/tencent/selectOrder',
  // 腾讯云订单代付
  doPayTencentCouldCutomerOrder: 'api/tencent/payOrder'
}

// 获取链接
function getConnect(data = {}) {
  let url = getApp().globalData.config['url'];
  data.openid = wx.getStorageSync('openid') || getApp().globalData.openid;
  data.mallId = Config['SaaSID'];
  var req = Request.createRequest({
    url: url + data['point_url'],
    data: data,
    method: 'POST'
  });
  return req();
}

// 上传图片
function uploadImage(img, data={}) {
  let url = getApp().globalData.config['url'];
  var req = null;
  data.mallId = Config['SaaSID']; 
  if (getApp().globalData.config['ENV'] === "CLOUD") {
    const imgBase64 = getApp().utils.fileToBase64(img);
    console.log(imgBase64, data);
    data.picture = imgBase64;
    req = Request.createRequest({
      url: url + "api/crm/upload",
      data: data,
      method: 'POST'
    });
  } else {
    req = Request.createUpload({
      url: url + "api/crm/upload",
      filePath: img,
      formData: data,
      name: 'picture',
      method: 'POST'
    });
  }
  return req();
}

// 上传文件
function uploadFile(file, data = {}) {
  let url = getApp().globalData.config['url'];
  var req = null;
  data.mallId = Config['SaaSID']; 
  if (getApp().globalData.config['ENV'] === "CLOUD") {
    const fileBase64 = getApp().utils.fileToBase64(file);
    console.log(fileBase64, data);
    data.file = fileBase64;
    req = Request.createRequest({
      url: url + "wxapi/file/uploadAnnex",
      data: data,
      method: 'POST'
    });
  } else {
    req = Request.createUpload({
      url: url + "wxapi/file/uploadAnnex",
      filePath: file,
      formData: data,
      name: 'file',
      method: 'POST'
    });
  }
  return req();
}

// 上传音频
function uploadVoice(img, data = {}) {
  let url = getApp().globalData.config['url'];
  var req = null;
  data.mallId = Config['SaaSID']; 
  if (getApp().globalData.config['ENV'] === "CLOUD") {
    const imgBase64 = getApp().utils.fileToBase64(img);
    console.log(imgBase64, data);
    data.picture = imgBase64;
    req = Request.createRequest({
      url: url + "wxapi/file/uploadAudio",
      data: data,
      method: 'POST'
    });
  } else {
    req = Request.createUpload({
      url: url + "wxapi/file/uploadAudio",
      filePath: img,
      formData: data,
      name: 'file',
      method: 'POST'
    });
  }
  return req();
}

module.exports = {
  agentApi: AgentAPI,
  adminApi: AdminAPI,
  getConnect: getConnect,
  uploadImage: uploadImage,
  uploadFile: uploadFile,
  uploadVoice: uploadVoice
}
